<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>活动信息</title>
<%@ include file="/page/include.jsp"%>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/statics/plugins/bootstrap-switch/bootstrap-switch.min.css" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/statics/plugins/bootstrap-daterangepicker/daterangepicker.css" />
<link rel="stylesheet" href="<%=basePath%>/statics/css/webform.css?v=20180104" />
<style type="text/css">
.form-group .btn {
    margin-bottom: 0px !important;
}
</style>
</head>
<body class="nav-md" style="background-color: #f7f7f7">
    <div class="container body">
        <div class="main_container">
            <div class="framebody" style="min-height: 100%;" role="main">
                <!-- <blockquote class="ui-elem-quote">活动信息编辑</blockquote> -->
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_content">
                                <form class="form-horizontal form-label-left" name="promotionForm" id="promotionForm" method="post"
                                    action="${pageContext.request.contextPath}/promotion/savePromotion">
                                    <input type="hidden" id="id" name="id" value="${promotion.id }">
                                    <div class="item form-group">
                                        <label class="control-label col-md-1 col-sm-1 col-xs-1" for="promotionCode"><span class="required"><font
                                                color="red">*</font></span>活动编码: 
                                        </label>
                                        <label class="control-label col-md-11 col-sm-11 col-xs-11 txtLeft">${promotion.promotionCode }</label>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-1 col-sm-1 col-xs-1" for="promotionType"><span class="required"><font
                                                color="red">*</font></span>活动类型: 
                                        </label>
                                        <div class="col-md-11 col-sm-11 col-xs-11">
                                            <c:forEach items="${promotionTypeList }" var="type">
                                                <label class="control-label" for="promotionType" style="margin-right:50px;">
                                                    <input name="promotionType"   value="${type.keyValue }" type="radio"
                                                        <c:choose>
                                                            <c:when test="${promotion.promotionType == type.keyValue }"> checked="true" </c:when>
                                                            <c:otherwise> disabled="disabled" </c:otherwise>
                                                        </c:choose>
                                                    class="form-control"> ${type.keyIntro }
                                                </label>
                                            </c:forEach>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-1 col-sm-1 col-xs-1" for="promotionName"><span class="required"><font
                                                color="red">*</font></span>活动名称: 
                                        </label>
                                        <label class="control-label col-md-11 col-sm-11 col-xs-11 txtLeft">${promotion.promotionName }</label>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-1 col-sm-1 col-xs-1" for="promotionTitle"><span class="required"><font
                                                color="red">*</font></span>活动标语: 
                                        </label>
                                        <label class="control-label col-md-11 col-sm-11 col-xs-11 txtLeft">${promotion.promotionTitle }</label>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-1 col-sm-1 col-xs-1" for="promotionDate"><span class="required"><font
                                                color="red">*</font></span>活动时间: </label>
                                        <label class="control-label col-md-11 col-sm-11 col-xs-11 txtLeft">
                                            <fmt:formatDate value="${promotion.beginTime }" type="both" /> ~
                                            <fmt:formatDate value="${promotion.endTime }" type="both" />
                                            <input type="hidden" id="promotionDate" value="<fmt:formatDate value="${promotion.beginTime }" type="both" /> - <fmt:formatDate value="${promotion.endTime }" type="both" />">
                                        </label>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-1 col-sm-1 col-xs-1" for="btnAddProduct"><span class="required"> <font
                                                color="red">*</font></span>活动商品:</label> 
                                        <div class="col-md-11 col-sm-11 col-xs-11">
                                            <table id="productTable" class="table"></table>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-1 col-sm-1 col-xs-1" for="promotionTargetDiv">活动对象:</label>
                                        <div class="col-md-11 col-sm-11 col-xs-11">
                                            <div class="target" id="promotionTargetDiv">
                                                <%-- <c:forEach items="${targetList }" var="target" varStatus="t">
                                                    <span name="targetSpan" id="targetSpan${t.index }" title="${target.customerCustomId }#${target.propertyValue }#${target.propertyName }">${target.targetTypeName }[${target.propertyName }]</span>
                                                </c:forEach>&nbsp; --%>
                                                <div class="selectedTargetDiv">
                                                    <dl class="selectedTargetDL" style="border-bottom: none;">
                                                        <dd>
                                                            <ul class="selectedTargetUL">
                                                                <c:forEach items="${targetList}" var="target" varStatus="t">
                                                                    <li class="targetLi${t.index }" title="${target.customerCustomId }#${target.propertyValue }#${target.propertyName }">
                                                                        <a href="javascript:void(0)">
                                                                            <b id="filter_name">${target.targetTypeName }</b>：
                                                                            <b id="filter_value" class="color">${target.propertyName}</b>
                                                                        </a>
                                                                    </li>
                                                                </c:forEach>
                                                            </ul>
                                                        </dd>
                                                    </dl>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- 活动规则模块 begin -->
                                    <%-- 定义活动规则DIV 隐藏或者显示 begin --%>
                                    <c:set var="ruleReduceDisplay" value="none"></c:set><%-- 满减DIV --%>
                                    <c:set var="ruleGiftDisplay" value="none"></c:set><%-- 满赠DIV --%>
                                    <c:set var="ruleDiscountDisplay" value="none"></c:set><%-- 折扣DIV --%>
                                    <c:choose>
                                        <c:when test="${promotionType == 1 }">
                                            <c:set var="ruleReduceDisplay" value="block"></c:set>
                                        </c:when>
                                        <c:when test="${promotionType == 2 }">
                                            <c:set var="ruleGiftDisplay" value="block"></c:set>
                                        </c:when>
                                        <c:otherwise>
                                            <c:set var="ruleDiscountDisplay" value="block"></c:set>
                                        </c:otherwise>
                                    </c:choose>
                                    <%-- 定义活动规则DIV 隐藏或者显示 end --%>
                                    
                                    <%-- 满减规则添加按钮 隐藏或者显示 end --%>
                                    <c:set var="ruleReduceAddBtnDisplay" value="inline"></c:set><%-- 满减DIV --%>
                                    <c:if test="${isLimit == 1 }">
                                        <c:set var="ruleReduceAddBtnDisplay" value="none"></c:set>
                                    </c:if>
                                    <%-- 满减规则添加按钮 隐藏或者显示 end --%>
                                    <%-- 1、满减活动规则块 div begin --%>
                                    <div id="ruleReduce" style="display: ${ruleReduceDisplay};">
                                        <div class="item form-group">
                                            <label class="control-label col-md-1 col-sm-1 col-xs-1" for="" style="padding-right: 0px;"><span class="required"> <font
                                                color="red">*</font></span>满减规则：</label>
                                            <div class="col-md-11 col-sm-11 col-xs-11">
                                                <input type="checkbox" name="isLimit" id="isLimit" disabled="true" <c:if test="${isLimit == 1 }"> checked="true" </c:if> /> <b>上不封顶</b><font color="gray">（“每X元减X元”的倍数自动计算优惠金额）</font>
                                            </div>
                                        </div>
                                        <div class="item form-group">
                                            <label class="control-label col-md-1 col-sm-1 col-xs-1" for="">&nbsp;</label>
                                            <div class="col-md-11 col-sm-11 col-xs-11" id="ruleReduceDiv">
                                                <c:if test="${not empty ruleReduceList }">
                                                    <c:forEach items="${ruleReduceList }" var="ruleReduce" varStatus="r">
                                                        <div class="item form-group">
                                                            <label class="control-label col-md-1 col-sm-1 col-xs-1 txtRight">订单金额满</label>
                                                            <label class="control-label col-md-2 col-sm-2 col-xs-2 txtCenter"><fmt:formatNumber type="number" value="${ruleReduce.orderMoney }" pattern="0.00" maxFractionDigits="2"/></label>
                                                            <label class="control-label col-md-1 col-sm-1 col-xs-1 txtCenter">元，减</label>
                                                            <label class="control-label col-md-2 col-sm-2 col-xs-2 txtCenter"><fmt:formatNumber type="number" value="${ruleReduce.reduceMoney }" pattern="0.00" maxFractionDigits="2"/></label>
                                                            <label class="control-label col-md-1 col-sm-1 col-xs-1 txtLeft">元。</label>
                                                        </div>
                                                    </c:forEach>
                                                    </div>
                                                </c:if>
                                            </div>
                                        </div>
                                    </div>
                                    <%-- 1、满减活动规则块 div end --%>
                                    <%-- 2、满赠活动规则块 div begin --%>
                                    <div id="ruleGift" style="display: ${ruleGiftDisplay};">
                                        <div class="item form-group">
                                            <label class="control-label col-md-1 col-sm-1 col-xs-1" for="" style="padding-right: 0px;"><span class="required"> <font
                                                color="red">*</font></span>满赠规则：</label>
                                            <div class="col-md-11 col-sm-11 col-xs-11" id="ruleGiftDiv">
                                                <c:if test="${not empty ruleGiftList }">
                                                    <c:forEach items="${ruleGiftList }" var="ruleGift" varStatus="r">
                                                        <div id="ruleGiftSetDiv${r.index }">
                                                            <div class="item form-group">
                                                                <div class="col-md-11 col-sm-11 col-xs-11 giftDiv">
                                                                    <div class="item form-group">
                                                                        <label class="control-label col-md-1 col-sm-1 col-xs-1">订单金额满</label>
                                                                        <label class="control-label col-md-2 col-sm-2 col-xs-2 txtCenter"><fmt:formatNumber type="number" value="${ruleGift.orderMoney }" pattern="0.00" maxFractionDigits="2"/></label>
                                                                        <label class="control-label col-md-1 col-sm-1 col-xs-1 txtCenter">元赠：</label>
                                                                    </div>
                                                                    <div class="item form-group">
                                                                        <span id="giftTypeTmp">
                                                                            <input type="radio" name="giftType${r.index}" value="1" 
                                                                                <c:choose>
                                                                                    <c:when test="${ruleGift.giftType == 1 }"> checked="true" </c:when>
                                                                                    <c:otherwise> disabled="disabled" </c:otherwise>
                                                                                </c:choose>
                                                                            validate="{required:true}">&nbsp;<label style="margin-right:50px;">商品</label>
                                                                            <input type="radio" name="giftType${r.index}" value="2" 
                                                                                <c:choose>
                                                                                    <c:when test="${ruleGift.giftType == 2 }"> checked="true" </c:when>
                                                                                    <c:otherwise> disabled="disabled" </c:otherwise>
                                                                                </c:choose>
                                                                            validate="{required:true}">&nbsp;<label style="margin-right:50px;">优惠券</label>
                                                                            <input type="radio" name="giftType${r.index}" value="3" 
                                                                                <c:choose>
                                                                                    <c:when test="${ruleGift.giftType == 3 }"> checked="true" </c:when>
                                                                                    <c:otherwise> disabled="disabled" </c:otherwise>
                                                                                </c:choose>
                                                                                validate="{required:true}">&nbsp;<label style="margin-right:50px;">积分</label>
                                                                        </span>
                                                                    </div>
                                                                    <div class="item form-group">
                                                                        <div id="giftType${r.index}">
                                                                            <c:choose>
                                                                                <c:when test="${ruleGift.giftType == 1 }">
                                                                                    <div class="item form-group">
                                                                                        <table id="giftTable${r.index}" class="table" title="${promotion.id }#${ruleGift.id }"></table>
                                                                                    </div>
                                                                                </c:when>
                                                                                <c:when test="${ruleGift.giftType == 2 }">
                                                                                    <input type="hidden" id="couponId${r.index}" name="couponId" value="${ruleGift.couponId }" />
                                                                                    <select class="selectpicker form-control col-md-12" id="couponCombo${r.index}" name="couponCombo" title="请选择赠送的优惠券">
                                                                                        <option value="">全部</option>
                                                                                    </select>
                                                                                </c:when>
                                                                                <c:otherwise>
                                                                                    <fmt:formatNumber type="number" value="${ruleGift.giftValue }" pattern="0.00" maxFractionDigits="2"/>
                                                                                </c:otherwise>
                                                                            </c:choose>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </c:forEach>
                                                </c:if>
                                            </div>
                                        </div>
                                    </div>
                                    <%-- 2、满赠活动规则块 div end --%>
                                    <%-- 3、折扣活动规则块 div begin --%>
                                    <div id="ruleDiscount" style="display: ${ruleDiscountDisplay};">
                                        <div class="item form-group">
                                            <label class="control-label col-md-1 col-sm-1 col-xs-1" for="" style="padding-right: 0px;"><span class="required"> <font
                                                color="red">*</font></span>折扣规则：</label>
                                            <div class="col-md-11 col-sm-11 col-xs-11" id="ruleDiscountDiv">
                                                <c:if test="${not empty ruleDiscountList }">
                                                    <c:forEach items="${ruleDiscountList }" var="ruleDiscount" varStatus="r">
                                                        <div id="ruleDiscountBaseDiv" class="col-md-12 col-sm-12 col-xs-12">
                                                            <div class="item form-group">
                                                                <label class="control-label col-md-1 col-sm-1 col-xs-1">订单金额满</label>
                                                                <label class="control-label col-md-1 col-sm-1 col-xs-1 txtCenter"><fmt:formatNumber type="number" value="${ruleDiscount.orderMoney }" pattern="0.00" maxFractionDigits="2"/></label>
                                                                <label class="control-label col-md-1 col-sm-1 col-xs-1 txtCenter">元，打</label>
                                                                <label class="control-label col-md-2 col-sm-2 col-xs-2 txtCenter"><fmt:formatNumber type="number" value="${ruleDiscount.discount }" pattern="0.00" maxFractionDigits="2"/></label>
                                                                <label class="control-label col-md-1 col-sm-1 col-xs-1 txtLeft">折。</label>
                                                            </div>
                                                        </div>
                                                    </c:forEach>
                                                </c:if>
                                            </div>
                                        </div>
                                    </div>
                                    <%-- 3、折扣活动规则块 div end --%>
                                    <!-- 活动规则模块 end -->
                                </form>
                                <div class="form-btn-content txtLeft">
                                     <a id="btn_back" class="btn btn-default">返回</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</body>
<script type="text/javascript" src="<%=basePath%>/js/promotion/promotion_detail.js?v=new Date()"></script>
</html>